package com.foreknow.demo10;

/**
 * @author shkstart
 * @create 2021-07-29 14:40
 */

/**
 * == 两个字符串对象 比较的是内存的地址
 * 如果想比较两个字符串内容是否相同使用equals
 */
public class Demo {
    public static void main(String[] args) {
        String s1="haha";
        String s2="haha";
        String s3=new String("haha");
        String s4=new String("haha");
        Integer i1=new Integer(20);
        Integer i2=new Integer(20);
        System.out.println(i1.equals(i2));
        System.out.println("**************");
        System.out.println(s1==s2);
        System.out.println(s1 == s3);
        System.out.println(s3.equals(s4));


        System.out.println("******************");
        Person p1 = new Person();
        p1.name = "atguigu";
        Person p2 = new Person();
        p2.name = "atguigu";
        System.out.println(p1.name .equals( p2.name)); //ture
        System.out.println(p1.name == p2.name); //true
        System.out.println(p1.name == "atguigu"); //true
        String s11 = new String("bcde");
        String s22 = new String("bcde");
        System.out.println(s11==s22); //false
    }
}
